! function(m, $) {
	m.plusReady(function() {
		var currentView = plus.webview.currentWebview(); // 获取 当前webview
		currentView.show('slide-in-right', 300); // 显示当前webview (方式,时间)
		plus.nativeUI.closeWaiting(); // 关闭系统 loading 等待框

		var map = null;
		! function() {
			var height = $(window).height() - 50;
			$('.maps-form-input').css('height', height);
			$('#map').css('height', height);
			setPoint(87.273870, 44.020128)
		}();

		function setPoint(y, x) {
			var em = document.getElementById("map");
			map = new BMap.Map("map");
			map.centerAndZoom(new BMap.Point(y, x), 13);
			var ws = plus.webview.create("mapsSerch.html", "mapsSerch.html", {
				right: "10px",
				top: '50px',
				height: '400px',
				width: '250px',
				background: 'transparent'
			});
			plus.webview.currentWebview().append(ws);
			map.addEventListener("click", showInfo);

			function showInfo(e) {
				if(!e.overlay) {
					var tabbar = plus.webview.getWebviewById("tabbar.html");
					tabbar ? tabbar.close() : '';
				}
			}

			var token = plus.storage.getItem('token');
			console.log(token)
			m.ajax(rutour.maps.maplist + token, {
				dataType: 'json',
				type: 'post',
				success: function(data) {
					console.log(data)
					for(var i = 0, point; point = data[i++];) {
						var pos = new BMap.Point(point.longitude, point.latitude);
						var marker = new BMap.Marker(pos);
						map.addOverlay(marker);
						! function(i) {
							marker.onclick = function() {
								openTab(i);
							}
						}(point)

					}
				},
				error: function(xhr, type, errorThrown) {
					//异常处理；
					console.log('登录失效!请重新登录');
				}

			})
		}
		window.addEventListener('serch', function(event) {
			var i = event.detail.i;
			var pt = new BMap.Point(i.longitude, i.latitude)
			map.clearOverlays();
			if(i.longitude && i.latitude) {
				map.centerAndZoom(pt, 15);
				var marker = new BMap.Marker(pt);
				map.addOverlay(marker);
				marker.onclick = function() {
					openTab(i)
				};
				marker.setAnimation(BMAP_ANIMATION_BOUNCE);
			} else {
				var marker = new BMap.Marker(new BMap.Point(87.273870, 44.020128));
				map.addOverlay(marker);
				map.setCenter(new BMap.Point(87.273870, 44.020128));
				map.setZoom(14);
			}

		});

		function openTab(i) {
			map.setCenter(new BMap.Point(i.longitude, i.latitude));
			map.setZoom(18);
			var tabbar = plus.webview.getWebviewById("tabbar.html");
			tabbar ? tabbar.close() : '';
			var tabbar = plus.webview.create('tabbar.html', 'tabbar.html', {
				width: '500px',
				height: '150px',
				left: '20%',
				bottom: '20px'
			}, {
				val: i
			});
			tabbar.show();
		}
	})
}(mui, jQuery)